/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tugasbesarjeni1.form.model;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import tugasbesarjeni1.Database.VCD.Vcd;

/**
 *
 * @author Indy
 */
public class VCDModel extends AbstractTableModel{
    private List<Vcd> list = new ArrayList<Vcd>();
   public void tambahVcd(Vcd vcd){
        list.add(vcd);
        fireTableRowsInserted(getRowCount(), getColumnCount());
    }
    public void hapusTable(int i, int row){
        list.remove(i);
        fireTableRowsDeleted(i, row);
    }

   public Vcd get(int row){
       return (Vcd) list.get(row);
   }
    public int getRowCount() {
        return list.size();
    }

    public int getColumnCount() {
        return 4;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex){
            case 0: return list.get(rowIndex).getKode();
            case 1: return list.get(rowIndex).getJudul();
            case 2: return list.get(rowIndex).getKategori();
            case 3: return list.get(rowIndex).getHargaSewa();
            default: return null;
        }
    }
    @Override
    public String getColumnName(int column){
        switch(column){
            case 0: return "kode";
            case 1: return "judul";
            case 2: return "kategori";
            case 3: return "Harga Sewa";
            default: return null;
        }
    }

}
